#include "TheaterSelectionWhiteboard.h"
#include "utility.h"

// Initialize the TheaterSelectionWhiteboard object
TheaterSelectionWhiteboard::TheaterSelectionWhiteboard(){
	//change this to pass in at one point
	numRows = 5;
	seatsPerRow = 5;
	seatsAvail = (numRows * seatsPerRow);
	rowSeatsAvail = new int[numRows];
	for (int i = 0; i < numRows; i++) {
		rowSeatsAvail[i] = seatsPerRow;
	}
}	

// De-allocate TheaterSelectionWhiteboard
TheaterSelectionWhiteboard::~TheaterSelectionWhiteboard(){
}	
    
// returns the number of seats that are left in the theater
int TheaterSelectionWhiteboard::getSeatsAvail(){
	return seatsAvail;
}	
// returns the number of seats left in a particular row
int TheaterSelectionWhiteboard::getRowSeatsAvail(int rowNum){
	return rowSeatsAvail[rowNum];
} 	

int TheaterSelectionWhiteboard::getSeatsPerRow(){
	return seatsPerRow;
}

int TheaterSelectionWhiteboard::getNumRows(){
	return numRows;
}
    
//sets the total number of seats left in the theater
void TheaterSelectionWhiteboard::setSeatsAvail(int value){
	seatsAvail = value;
}

//sets the number of seats left per row
void TheaterSelectionWhiteboard::setRowSeatsAvail(int rowNum, int value){
	rowSeatsAvail[rowNum] = value;
} 	
//resets the theater whiteboard data for next movie
void TheaterSelectionWhiteboard::movieOver(){
	seatsAvail = (numRows * seatsPerRow);
	for (int i=0; i< numRows; i++){
		rowSeatsAvail[i] = seatsPerRow;
	}
}	
	
//decrements total number of avail seats by value passed in
void TheaterSelectionWhiteboard::decrementSeatsAvail(int value){
	seatsAvail -= value;
}	

//decrements number of avail seats in a row by value passed in
void TheaterSelectionWhiteboard::decrementRowSeatsAvail(int rowNum){
		rowSeatsAvail[rowNum]--;
} 	

int TheaterSelectionWhiteboard::findRowWithMostSeatsAvail(){
	int rowSelection = 0;
	int maxNumOfPeopleInRow = 0;
	for (int i=0; i<numRows; i++){
		if (rowSeatsAvail[i] > maxNumOfPeopleInRow){
			maxNumOfPeopleInRow = rowSeatsAvail[i];
			rowSelection = i;
		}
	}
	return rowSelection;
}	